package visualcbir.visualstructures.ring;

import visualcbir.*;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
import java.util.ArrayList;
import visualcbir.exception.NullBackStructureException;
import visualcbir.util.VSUtils;

/**
 *
 * @author sheila
 */
public class VSRingBackStructureView implements IBackStructureView {
    private ArrayList <Polygon> aoPolygons;

    @Override
    public void drawBackStructure(Graphics g) throws NullBackStructureException{
        if( aoPolygons == null ){
            throw new NullBackStructureException();
        }
        Graphics2D g2d=((Graphics2D)g);
        g2d.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f));
        Color oColor= Color.white;
        for(int y=0; y<aoPolygons.size()-1; y++)
            oColor = oColor.darker();

        for (int i = this.aoPolygons.size()-1; i >= 0; i--) {
            g2d.setColor(oColor);
            g2d.fill(aoPolygons.get(i));
            oColor=oColor.brighter();
            g2d.setColor(Color.red);
            g2d.setStroke(new BasicStroke(2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND, 10.0f, null, 0.0f));
            g2d.draw(aoPolygons.get(i));
        }
        VSUtils.resetGraphics(g);
    }

    @Override
    public void setObject(Object oObject) {
        this.aoPolygons=(ArrayList<Polygon>)oObject;
    }
}
